package org.qiyu.live.user.provider;

import jakarta.annotation.Resource;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.qiyu.live.user.constants.UserTagsEnum;
import org.qiyu.live.user.provider.service.IUserService;
import org.qiyu.live.user.provider.service.IUserTagService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
 * @Author 朝问道
 * @Date 2023年12月28日 9:25
 * @Description 用户中台dubbo服务提供者
 */

@SpringBootApplication
@EnableDubbo
@EnableDiscoveryClient
public class UserProviderApplication implements ApplicationRunner {
    public static void main(String[] args) {
//        SpringApplication.run(UserProviderApplication.class, args);
        SpringApplication springApplication = new SpringApplication(UserProviderApplication.class);
        springApplication.setWebApplicationType(WebApplicationType.NONE); // 不需要使用tomcat,是纯粹的netty应用进程
        springApplication.run(args);
    }


    @Resource
    private IUserTagService userTagService;
    @Override
    public void run(ApplicationArguments args) throws Exception {

        long userID = 1001L;
        System.out.println("初始化：将userID=1001用户的vip标签去除");
        userTagService.cancelTag(userID, UserTagsEnum.IS_VIP);
        System.out.println("用户是否为老用户："+  userTagService.containTag(userID, UserTagsEnum.IS_OLD_USER));
        System.out.println("用户是否为vip："+  userTagService.containTag(userID, UserTagsEnum.IS_VIP));
        userTagService.setTag(userID, UserTagsEnum.IS_VIP);
        System.out.println("新增userID=1001用户的vip标签");
        System.out.println("再次查询用户是否为vip："+  userTagService.containTag(userID, UserTagsEnum.IS_VIP));
    }
}
